package com.naiterui.ehp.bs.esign.utils;

import com.naiterui.ehp.bp.constants.EsignServiceProviderEnum;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 电子签名意愿签署
 */
public enum EsignWillTypeEnum {

    NETRAIN_SIGN_PWD("1", "密码", EsignServiceProviderEnum.NETRAIN.getServiceId()),

    /**
     * 电子签名意愿签署：
     */
    BJCA_SIGN_PWD("1", "密码", EsignServiceProviderEnum.BJCA.getServiceId()),
    BJCA_FINGER_PRINT("2", "指纹识别", EsignServiceProviderEnum.BJCA.getServiceId()),

    WUKONG_FACE_ZHIMA_XY("FACE_ZHIMA_XY", "人脸识别", EsignServiceProviderEnum.ESIGN_WUKONG_SDK.getServiceId()),
    WUKONG_SIGN_PWD("SIGN_PWD", "密码", EsignServiceProviderEnum.ESIGN_WUKONG_SDK.getServiceId()),
    WUKONG_CODE_MESSAGE("CODE_SMS", "短信验证码", EsignServiceProviderEnum.ESIGN_WUKONG_SDK.getServiceId()),

    SCCA_SIGN_PWD("1", "密码", EsignServiceProviderEnum.SCCA.getServiceId()),

    ;

    EsignWillTypeEnum(String value, String name, String service) {
        this.value = value;
        this.name = name;
        this.service = service;
    }

    /**
     * 签名类型值
     */
    private String value;

    /**
     * 类型名称
     */
    private String name;

    /**
     * 签名服务商：1:BJCA, 2:E签宝
     */
    private String service;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getService() {
        return service;
    }

    public void setService(String service) {
        this.service = service;
    }

    /**
     * 根据服务商获取意愿签署列表
     * @param service
     * @return
     */
    public static List<EsignWillTypeEnum> getByService(String service){
        return Arrays.asList(EsignWillTypeEnum.values()).stream()
            .filter(s -> s.getService().equals(service)).collect(Collectors.toList());
    }

    /**
     * 根据服务商获取意愿签署值列表
     * @param service
     * @return
     */
    public static Object[] getValuesByService(String service){
        List<String> list = Arrays.asList(EsignWillTypeEnum.values()).stream()
            .filter(s -> s.getService().equals(service)).map(s -> s.getValue()).collect(Collectors.toList());
        //添加腾讯云刷脸签署方式
        list.add("FACE_TECENT_CLOUD_H5");
        return list.toArray();
    }
}
